// pages/select/select.js
const app = getApp();
var _tousList = [
  {
    name: '类 型 6',
    coverImgUrl: '../../images/imgs/img_16.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_16.png?sign=d6e07072f5ef792daba5b200784f1431&t=1617901774"
  }, {
    name: '类 型 1',
    coverImgUrl: '../../images/imgs/img_10.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_10.png?sign=b15d8b2829eac4ae150b6ce6ef7c719f&t=1617901453"
  }, {
    name: '类 型 3',
    coverImgUrl: '../../images/imgs/img_12.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_12.png?sign=8e106bb7398c395d00b1f35121261c8c&t=1618227236"
  }, {
    name: '类 型 7',
    coverImgUrl: '../../images/imgs/img_17.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_17.png?sign=df0b45dc0a39469b4fcc996bc3370ebf&t=1618225636"
  },
  {
    name: '类 型 5',
    coverImgUrl: '../../images/imgs/img_15.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_15.png?sign=b9854d5f1d635b7f1b3a22ddab2b3012&t=1618227289"
  }, {
    name: '类 型 4',
    coverImgUrl: '../../images/imgs/img_13.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_13.png?sign=c02bf172de4ba0a44cd927049d63ae54&t=1617901745"
  }, {
    name: '类 型 2',
    coverImgUrl: '../../images/imgs/img_11.png',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_11.png?sign=8f7a74c9d85c9abc3281034d222048e0&t=1617901671"
  }, {
    name: '类 型 8',
    coverImgUrl: '../../images/imgs/img_18.jpg',
    netImgUrl: "https://6c64-ldw1213-1gy4lb2r7470538e-1302607420.tcb.qcloud.la/img_18.png?sign=e8d9c34646440aafe425e47300128786&t=1617932561"
  }
]

Page({

  /**
   * 页面的初始数据
   */
  data: {
    touList: _tousList
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  bgImgLoad(){
    let flag = app.globalData.flag
    if (flag) {

    } else {

      wx.showToast({
        title: '请点击选择相框',
        icon: 'none',
        duration: 2500,
        mask: false
      });
      app.globalData.flag = true
    }
  },
  //点击选项进入详情页
  detail: function (e) {
    // console.log(e)
    var touNum = e.currentTarget.dataset.tounum
    // console.log(yangzhiNum)
    switch (touNum) {
      case 0:
        app.globalData.toubgsrc = _tousList[0].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      case 1:
        app.globalData.toubgsrc = _tousList[1].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      case 2:
        app.globalData.toubgsrc = _tousList[2].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      case 3:
        app.globalData.toubgsrc = _tousList[3].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      case 4:
        app.globalData.toubgsrc = _tousList[4].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      case 5:
        app.globalData.toubgsrc = _tousList[5].coverImgUrl
        wx.navigateTo({
          url: '../madeph/madeph'
        })
        break;
      default:
        //do nothing
    }
  },
  selectBorder(e){
    if (!e.currentTarget.dataset.url){
      wx.showModal({
        title: '提示',
        content: '头像框无法找到了哦!'
      })
    }else{
      // 选择头像框路径 存入全局
      app.globalData.borderImgs = e.currentTarget.dataset.url
      // app.globalData.borderImgs = "http://ww1.sinaimg.cn/large/007Wxehkly1gp016dx44sj31tm1tmqie.jpg"
      wx.showToast({
        title: '选择头像框成功',
        icon:'none',
        duration:1000,
        success:function(){
          wx.redirectTo({
            url: '../index/index',
          })
        }
      })
    }
  },
  onShareAppMessage() {
    return {
      title: "我发现了一个好玩的小程序,快来跟我一起生成头像框吧!",
      path: '/pages/select/select',
      imageUrl: '../../images/share.png'
    }
  }
})